package com.tcc.task;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.tcc.qa.test.util.BaseTest;
import com.tcc.qa.test.util.ButtonFinder;
import com.tcc.qa.test.util.CheckBoxFinder;
import com.tcc.qa.test.util.MsgFinder;
import com.tcc.qa.test.util.SelectFinder;

@SuppressWarnings("unused")
public class ClearTaskData extends BaseTest {

//*************************************************************************************************
	//
	@Test(description = "Delete All Task", priority = 1)
	public void deleteTask() {
		getWebDriver().get(super.getTestDomainURL() +"q?pg=papp&a=tasks&v=listTasks&cx=u");
		CheckBoxFinder.getCheckBoxCheckAll(getWebDriver()).click();
		ButtonFinder.getTableButton(getWebDriver(), "Delete").click();
		Assert.assertEquals(getWebDriver().switchTo().alert().getText(), "Do you really want to delete the selected item(s)?");
		getWebDriver().switchTo().alert().accept();
	}
//**************************************************************************************************
	@Test(description = "Delete All Categories", priority = 2)
	public void deleteCategory() {
		getWebDriver().get(super.getTestDomainURL() +"q?cx=u&pg=papp&tg=Tasks-prefCategory");
		SelectFinder.getSelectOption(getWebDriver(), "categories", 0).click();
		ButtonFinder.getButtonByTitle(getWebDriver(), "Delete").click();
		Assert.assertTrue(SelectFinder.isEmpty(getWebDriver(), "categories"));
		ButtonFinder.getInputButtonByValue(getWebDriver(), "Save").click();
		Assert.assertEquals(MsgFinder.getMsgDiv(getWebDriver()).getText(), "Categories have been saved successfully.");
	}
//**************************************************************************************************
	@Test(description = "Delete All Status", priority=3)
	public void deleteStatus(){
		getWebDriver().get(super.getTestDomainURL() +"PageServlet?cx=u&pg=papp&tg=Tasks-prefStatus");
		for (int i=1 ; i<4; i++){
	        SelectFinder.getSelectOption(getWebDriver(), "statuses", 1).click(); 
	        ButtonFinder.getButtonByTitle(getWebDriver(), "Delete").click();
		}
        ButtonFinder.getInputButtonByValue(getWebDriver(), "Save").click();
        Assert.assertEquals(MsgFinder.getMsgDiv(getWebDriver()).getText(), "Status list has been updated.");
	}
}

   